package com.lifeCycle.bean;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;

@Component
@Repository
@Controller
public class Car implements InitializingBean, DisposableBean, BeanPostProcessor {

	public Car() {
		super();
		System.out.println("Car.Car()");
	}

	public void service() {
		System.out.println("Car.service(......)");
	}

	 @Override
	 public void afterPropertiesSet() throws Exception {
	 System.out.println("Car.afterPropertiesSet()");
	 }

	// @PostConstruct
	// public void postConstruct() {
	// System.out.println("Car.postConstruct()");
	// }

	public void init() {
		System.out.println("Car.init()");
	}

	@Override
	public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
		System.out.println("Car.postProcessBeforeInitialization(---)>" + bean + "+" + beanName);
		return bean;
	}

	/**
	 * 
	 * *************************
	 */

	 @Override
	 public void destroy() throws Exception {
	 System.out.println("Car.destroy()");
	 }

	public void destoryMethod() {
		System.out.println("Car.destoryMethod()");
	}

	// @PreDestroy
	// public void perDestroy() {
	// System.out.println("Car.perDestroy()");
	// }

	@Override
	public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
		System.out.println("Car.postProcessAfterInitialization()>" + bean + "+" + beanName);
		return bean;
	}
}
